/**
 *
 */
import Util;
import OpenApi;

import EndpointUtil;

extends OpenApi;

init(config: OpenApi.Config){
  super(config);
  @endpointRule = '';
  
  checkConfig(config);
  @endpoint = getEndpoint('eslengine', @regionId, @endpointRule, @network, @suffix, @endpointMap, @endpoint);
}

function getEndpoint(productId: string, regionId: string, endpointRule: string, network: string, suffix: string, endpointMap: map[string]string, endpoint: string) throws: string{
  if (!Util.empty(endpoint)) {
    return endpoint;
  }

  if (!Util.isUnset(endpointMap) && !Util.empty(endpointMap[regionId])) {
    return endpointMap[regionId];
  }
  return EndpointUtil.getEndpointRules(productId, regionId, endpointRule, network, suffix);
}
model SendOrderRequest {
  head?: string(name='Head'),
  parameters?: string(name='Parameters'),
}

model SendOrderResponseBody = {
  message?: string(name='Message'),
  errorMessage?: string(name='ErrorMessage'),
  requestId?: string(name='RequestId'),
  errorCode?: int32(name='ErrorCode'),
  success?: boolean(name='Success'),
}

model SendOrderResponse = {
  headers: map[string]string(name='headers'),
  body: SendOrderResponseBody(name='body'),
}

async function sendOrderWithOptions(request: SendOrderRequest, runtime: Util.RuntimeOptions): SendOrderResponse {
  Util.validateModel(request);
  var req = new OpenApi.OpenApiRequest{ 
    body = Util.toMap(request),
  };
  return doRPCRequest('SendOrder', '2019-01-20', 'HTTPS', 'POST', 'AK', 'json', req, runtime);
}

async function sendOrder(request: SendOrderRequest): SendOrderResponse {
  var runtime = new Util.RuntimeOptions{};
  return sendOrderWithOptions(request, runtime);
}

model SendCommandRequest {
  head?: string(name='Head'),
  parameters?: string(name='Parameters'),
}

model SendCommandResponseBody = {
  message?: string(name='Message'),
  errorMessage?: string(name='ErrorMessage'),
  requestId?: string(name='RequestId'),
  errorCode?: int32(name='ErrorCode'),
  success?: boolean(name='Success'),
}

model SendCommandResponse = {
  headers: map[string]string(name='headers'),
  body: SendCommandResponseBody(name='body'),
}

async function sendCommandWithOptions(request: SendCommandRequest, runtime: Util.RuntimeOptions): SendCommandResponse {
  Util.validateModel(request);
  var req = new OpenApi.OpenApiRequest{ 
    body = Util.toMap(request),
  };
  return doRPCRequest('SendCommand', '2019-01-20', 'HTTPS', 'POST', 'AK', 'json', req, runtime);
}

async function sendCommand(request: SendCommandRequest): SendCommandResponse {
  var runtime = new Util.RuntimeOptions{};
  return sendCommandWithOptions(request, runtime);
}

model ActiveMboxDeviceRequest {
  deviceType?: string(name='DeviceType', description='deviceType'),
  companyId?: string(name='CompanyId', description='companyId'),
  groupName?: string(name='GroupName', description='groupName'),
  appVersion?: string(name='AppVersion', description='appVersion'),
  productCode?: string(name='ProductCode', description='productCode'),
  registerId?: string(name='RegisterId', description='registerId'),
  accountName?: string(name='AccountName', description='accountName'),
  groupId?: string(name='GroupId', description='groupId'),
  deviceMac?: string(name='DeviceMac', description='deviceMac'),
  appCode?: string(name='AppCode', description='appCode'),
  deviceName?: string(name='DeviceName', description='deviceName'),
}

model ActiveMboxDeviceResponseBody = {
  totalCount?: long(name='TotalCount', description='totalCount'),
  requestId?: string(name='RequestId', description='requestId'),
  errorMsg?: string(name='ErrorMsg', description='errorMsg'),
  data?: string(name='Data', description='data'),
  errorCode?: int32(name='ErrorCode', description='errorCode'),
  success?: boolean(name='Success', description='success'),
}

model ActiveMboxDeviceResponse = {
  headers: map[string]string(name='headers'),
  body: ActiveMboxDeviceResponseBody(name='body'),
}

async function activeMboxDeviceWithOptions(request: ActiveMboxDeviceRequest, runtime: Util.RuntimeOptions): ActiveMboxDeviceResponse {
  Util.validateModel(request);
  var req = new OpenApi.OpenApiRequest{ 
    body = Util.toMap(request),
  };
  return doRPCRequest('ActiveMboxDevice', '2019-01-20', 'HTTPS', 'POST', 'AK', 'json', req, runtime);
}

async function activeMboxDevice(request: ActiveMboxDeviceRequest): ActiveMboxDeviceResponse {
  var runtime = new Util.RuntimeOptions{};
  return activeMboxDeviceWithOptions(request, runtime);
}

